package com.zhongkun.datahome.service.domain;

import java.math.BigDecimal;

import com.zhongkun.datahome.service.constant.MaterialTypeEnum;
import com.zhongkun.datahome.service.req.cmd.material.HouseMaterialCmd;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * 房产材料清单对象 house_material
 * 
 * @author ruoyi
 * @date 2025-04-14
 */
@Data
public class HouseMaterial extends BaseEntity {
    @ApiModelProperty("房产id")
    private Long houseId;

    @ApiModelProperty("材料类型")
    private String materialType;

    @ApiModelProperty("材料id")
    private Long materialId;

    @ApiModelProperty("数量")
    private BigDecimal quantity;

    @ApiModelProperty("所属空间")
    private String room;

    @ApiModelProperty("渠道")
    private Integer channel;

    @ApiModelProperty("remark")
    private String remark;

    public static HouseMaterial of(Long houseId, HouseMaterialCmd.HouseMaterialItemCmd cmd) {
        HouseMaterial houseMaterial = new HouseMaterial();
        houseMaterial.setHouseId(houseId);
        houseMaterial.setMaterialType(MaterialTypeEnum.COMMON_SKU.getType());
        houseMaterial.update(cmd);
        return houseMaterial;
    }

    public void update(HouseMaterialCmd.HouseMaterialItemCmd cmd) {
        this.setMaterialId(cmd.getMaterialId());
        this.setQuantity(cmd.getQuantity());
        this.setRoom(cmd.getRoom());
        this.setChannel(cmd.getChannel());
    }
}
